package cn.bearspark.article.provider.rpc;

import cn.bearspark.article.dto.category.AddCategoryDTO;
import cn.bearspark.article.dto.category.CategoryDTO;
import cn.bearspark.article.dto.category.CategorySimpleDTO;
import cn.bearspark.article.dto.category.ModifyCategoryDTO;
import cn.bearspark.article.provider.service.CategoryService;
import cn.bearspark.article.rpc.CategoryRpc;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author f
 */
@Component
@DubboService
public class CategoryRpcImpl implements CategoryRpc {

    private final CategoryService categoryService;

    public CategoryRpcImpl(CategoryService categoryService) {
        this.categoryService = categoryService;
    }

    @Override
    public void add(AddCategoryDTO addCategoryDTO) {
        categoryService.add(addCategoryDTO);
    }

    @Override
    public CategoryDTO get(long userId, long categoryId) {
        return categoryService.get(userId, categoryId);
    }

    @Override
    public void modify(ModifyCategoryDTO modifyCategoryDTO) {
        categoryService.modify(modifyCategoryDTO);
    }

    @Override
    public void delete(long userId, long categoryId) {
        categoryService.delete(userId, categoryId);
    }

    @Override
    public List<CategorySimpleDTO> list(long userId, long listedUserId) {
        return categoryService.listByListedUserId(userId, listedUserId);
    }
}
